{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 83,
   "metadata": {},
   "outputs": [],
   "source": [
    "import sys\n",
    "import os\n",
    "from os.path import dirname, realpath, join\n",
    "base_dir = dirname(dirname(os.getcwd()))\n",
    "\n",
    "import pandas as pd\n",
    "from os.path import join"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'/Users/haithamelmarakeby/PycharmProjects/pnet2'"
      ]
     },
     "execution_count": 84,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "base_dir"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## SUC Fusions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "metadata": {},
   "outputs": [],
   "source": [
    "sys.path.insert(0, base_dir)\n",
    "from config_path import PROSTATE_DATA_PATH, PLOTS_PATH"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "metadata": {},
   "outputs": [],
   "source": [
    "# fusions_file = join(PROSTATE_DATA_PATH, 'raw_data/outputs_su2c_tcga_all_samples_n=980_star_fusion.tsv')\n",
    "fusions_file = join(PROSTATE_DATA_PATH, 'raw_data/outputs_p1000_n=660_star_fusion.tsv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "metadata": {},
   "outputs": [],
   "source": [
    "fusions_data = pd.read_csv(fusions_file, sep='\\t',index_col=1 )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Unnamed: 0</th>\n",
       "      <th>seq_type</th>\n",
       "      <th>#FusionName</th>\n",
       "      <th>JunctionReadCount</th>\n",
       "      <th>SpanningFragCount</th>\n",
       "      <th>FFPM</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>sample</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>MO_1008-Tumor_Dura</th>\n",
       "      <td>0</td>\n",
       "      <td>tcap</td>\n",
       "      <td>EIF4A2--ETV5</td>\n",
       "      <td>137.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2.5101</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>MO_1012-Tumor-Subcutaneous_nodule</th>\n",
       "      <td>1</td>\n",
       "      <td>polyA</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>MO_1013-Tumor</th>\n",
       "      <td>2</td>\n",
       "      <td>polyA</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>MO_1014-Tumor</th>\n",
       "      <td>3</td>\n",
       "      <td>polyA</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>MO_1015-Tumor</th>\n",
       "      <td>4</td>\n",
       "      <td>tcap</td>\n",
       "      <td>TMPRSS2--ERG</td>\n",
       "      <td>117.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2.8226</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                   Unnamed: 0 seq_type   #FusionName  \\\n",
       "sample                                                                 \n",
       "MO_1008-Tumor_Dura                          0     tcap  EIF4A2--ETV5   \n",
       "MO_1012-Tumor-Subcutaneous_nodule           1    polyA           NaN   \n",
       "MO_1013-Tumor                               2    polyA           NaN   \n",
       "MO_1014-Tumor                               3    polyA           NaN   \n",
       "MO_1015-Tumor                               4     tcap  TMPRSS2--ERG   \n",
       "\n",
       "                                   JunctionReadCount  SpanningFragCount  \\\n",
       "sample                                                                    \n",
       "MO_1008-Tumor_Dura                             137.0                0.0   \n",
       "MO_1012-Tumor-Subcutaneous_nodule                NaN                NaN   \n",
       "MO_1013-Tumor                                    NaN                NaN   \n",
       "MO_1014-Tumor                                    NaN                NaN   \n",
       "MO_1015-Tumor                                  117.0                0.0   \n",
       "\n",
       "                                     FFPM  \n",
       "sample                                     \n",
       "MO_1008-Tumor_Dura                 2.5101  \n",
       "MO_1012-Tumor-Subcutaneous_nodule     NaN  \n",
       "MO_1013-Tumor                         NaN  \n",
       "MO_1014-Tumor                         NaN  \n",
       "MO_1015-Tumor                      2.8226  "
      ]
     },
     "execution_count": 88,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fusions_data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(682, 6)"
      ]
     },
     "execution_count": 89,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fusions_data.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 90,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "660"
      ]
     },
     "execution_count": 90,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(fusions_data.index.unique())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['EIF4A2--ETV5', nan, 'TMPRSS2--ERG', 'TMPRSS2--ETV4',\n",
       "       'RARA--SEPT9', 'KIAA1549--BRAF', 'SLC45A3--ETV1', 'THRAP3--RPN1',\n",
       "       'TMPRSS2--ETV1', 'TBL1XR1--PIK3CA', 'STAT3--ETV4',\n",
       "       'NOTCH2--PDE4DIP', 'NDRG1--ERG', 'ERG--TMPRSS2', 'SUZ12--NF1',\n",
       "       'TMPRSS2--BRAF', 'SLC45A3--ERG', 'TMPRSS2--KLF4',\n",
       "       'HMGN2P46--TMPRSS2', 'TMPRSS2--ETV5', 'HMGN2P46--HSP90AA1',\n",
       "       'KLK2--FGFR2', 'AFDN--SYK', 'CLTC--ETV4', 'NDRG1--MYC',\n",
       "       'BIRC6--EML4', 'TMPRSS2--MLLT3', 'TCF7L2--VTI1A', 'KLK2--ETV1',\n",
       "       'GNA11--CALR', 'CUX1--PDE4DIP', 'NSD1--FGFR4', 'YWHAE--ETV1',\n",
       "       'ARHGAP5--ATF1', 'NCOA2--NSD3'], dtype=object)"
      ]
     },
     "execution_count": 92,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fusions_data['#FusionName'].unique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "35"
      ]
     },
     "execution_count": 91,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(fusions_data['#FusionName'].unique())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "g1= fusions_data['#FusionName'].str.split('--', expand = True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [],
   "source": [
    "fusions_data['gene1'] = g1[0]\n",
    "fusions_data['gene2'] = g1[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fusions_data['']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Unnamed: 0</th>\n",
       "      <th>seq_type</th>\n",
       "      <th>#FusionName</th>\n",
       "      <th>JunctionReadCount</th>\n",
       "      <th>SpanningFragCount</th>\n",
       "      <th>FFPM</th>\n",
       "      <th>gene1</th>\n",
       "      <th>gene2</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>sample</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>MO_1008-Tumor_Dura</th>\n",
       "      <td>0</td>\n",
       "      <td>tcap</td>\n",
       "      <td>EIF4A2--ETV5</td>\n",
       "      <td>137.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2.5101</td>\n",
       "      <td>EIF4A2</td>\n",
       "      <td>ETV5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>MO_1012-Tumor-Subcutaneous_nodule</th>\n",
       "      <td>1</td>\n",
       "      <td>polyA</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>MO_1013-Tumor</th>\n",
       "      <td>2</td>\n",
       "      <td>polyA</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>MO_1014-Tumor</th>\n",
       "      <td>3</td>\n",
       "      <td>polyA</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>MO_1015-Tumor</th>\n",
       "      <td>4</td>\n",
       "      <td>tcap</td>\n",
       "      <td>TMPRSS2--ERG</td>\n",
       "      <td>117.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2.8226</td>\n",
       "      <td>TMPRSS2</td>\n",
       "      <td>ERG</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                   Unnamed: 0 seq_type   #FusionName  \\\n",
       "sample                                                                 \n",
       "MO_1008-Tumor_Dura                          0     tcap  EIF4A2--ETV5   \n",
       "MO_1012-Tumor-Subcutaneous_nodule           1    polyA           NaN   \n",
       "MO_1013-Tumor                               2    polyA           NaN   \n",
       "MO_1014-Tumor                               3    polyA           NaN   \n",
       "MO_1015-Tumor                               4     tcap  TMPRSS2--ERG   \n",
       "\n",
       "                                   JunctionReadCount  SpanningFragCount  \\\n",
       "sample                                                                    \n",
       "MO_1008-Tumor_Dura                             137.0                0.0   \n",
       "MO_1012-Tumor-Subcutaneous_nodule                NaN                NaN   \n",
       "MO_1013-Tumor                                    NaN                NaN   \n",
       "MO_1014-Tumor                                    NaN                NaN   \n",
       "MO_1015-Tumor                                  117.0                0.0   \n",
       "\n",
       "                                     FFPM    gene1 gene2  \n",
       "sample                                                    \n",
       "MO_1008-Tumor_Dura                 2.5101   EIF4A2  ETV5  \n",
       "MO_1012-Tumor-Subcutaneous_nodule     NaN      NaN   NaN  \n",
       "MO_1013-Tumor                         NaN      NaN   NaN  \n",
       "MO_1014-Tumor                         NaN      NaN   NaN  \n",
       "MO_1015-Tumor                      2.8226  TMPRSS2   ERG  "
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fusions_data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [],
   "source": [
    "unique_genes = set(list(fusions_data['gene1'].unique()) + list(fusions_data['gene2'].unique()))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "46"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(unique_genes)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [],
   "source": [
    "g1_df = pd.crosstab(fusions_data.index, fusions_data['gene1'])\n",
    "g2_df = pd.crosstab(fusions_data.index, fusions_data['gene2'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(299, 24)"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "g1_df.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(299, 23)"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "g2_df.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [],
   "source": [
    "fusions_matrix = pd.concat([g1_df, g2_df], axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(299, 47)"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fusions_matrix.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>AFDN</th>\n",
       "      <th>ARHGAP5</th>\n",
       "      <th>BIRC6</th>\n",
       "      <th>CLTC</th>\n",
       "      <th>CUX1</th>\n",
       "      <th>EIF4A2</th>\n",
       "      <th>ERG</th>\n",
       "      <th>GNA11</th>\n",
       "      <th>HMGN2P46</th>\n",
       "      <th>KIAA1549</th>\n",
       "      <th>...</th>\n",
       "      <th>MYC</th>\n",
       "      <th>NF1</th>\n",
       "      <th>NSD3</th>\n",
       "      <th>PDE4DIP</th>\n",
       "      <th>PIK3CA</th>\n",
       "      <th>RPN1</th>\n",
       "      <th>SEPT9</th>\n",
       "      <th>SYK</th>\n",
       "      <th>TMPRSS2</th>\n",
       "      <th>VTI1A</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>row_0</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>MO_1008-Tumor_Dura</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>MO_1015-Tumor</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>MO_1040-Tumor</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>MO_1054-Tumor</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>MO_1071-Tumor</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 47 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                    AFDN  ARHGAP5  BIRC6  CLTC  CUX1  EIF4A2  ERG  GNA11  \\\n",
       "row_0                                                                      \n",
       "MO_1008-Tumor_Dura     0        0      0     0     0       1    0      0   \n",
       "MO_1015-Tumor          0        0      0     0     0       0    0      0   \n",
       "MO_1040-Tumor          0        0      0     0     0       0    0      0   \n",
       "MO_1054-Tumor          0        0      0     0     0       0    0      0   \n",
       "MO_1071-Tumor          0        0      0     0     0       0    0      0   \n",
       "\n",
       "                    HMGN2P46  KIAA1549  ...    MYC  NF1  NSD3  PDE4DIP  \\\n",
       "row_0                                   ...                              \n",
       "MO_1008-Tumor_Dura         0         0  ...      0    0     0        0   \n",
       "MO_1015-Tumor              0         0  ...      0    0     0        0   \n",
       "MO_1040-Tumor              0         0  ...      0    0     0        0   \n",
       "MO_1054-Tumor              0         0  ...      0    0     0        0   \n",
       "MO_1071-Tumor              0         0  ...      0    0     0        0   \n",
       "\n",
       "                    PIK3CA  RPN1  SEPT9  SYK  TMPRSS2  VTI1A  \n",
       "row_0                                                         \n",
       "MO_1008-Tumor_Dura       0     0      0    0        0      0  \n",
       "MO_1015-Tumor            0     0      0    0        0      0  \n",
       "MO_1040-Tumor            0     0      0    0        0      0  \n",
       "MO_1054-Tumor            0     0      0    0        0      0  \n",
       "MO_1071-Tumor            0     0      0    0        0      0  \n",
       "\n",
       "[5 rows x 47 columns]"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fusions_matrix.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {},
   "outputs": [],
   "source": [
    "ind_df = pd.DataFrame(index=fusions_data.index.unique())\n",
    "fusions_matrix_full = ind_df.join(fusions_matrix)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(660, 47)"
      ]
     },
     "execution_count": 63,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fusions_matrix_full.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>AFDN</th>\n",
       "      <th>ARHGAP5</th>\n",
       "      <th>BIRC6</th>\n",
       "      <th>CLTC</th>\n",
       "      <th>CUX1</th>\n",
       "      <th>EIF4A2</th>\n",
       "      <th>ERG</th>\n",
       "      <th>GNA11</th>\n",
       "      <th>HMGN2P46</th>\n",
       "      <th>KIAA1549</th>\n",
       "      <th>...</th>\n",
       "      <th>MYC</th>\n",
       "      <th>NF1</th>\n",
       "      <th>NSD3</th>\n",
       "      <th>PDE4DIP</th>\n",
       "      <th>PIK3CA</th>\n",
       "      <th>RPN1</th>\n",
       "      <th>SEPT9</th>\n",
       "      <th>SYK</th>\n",
       "      <th>TMPRSS2</th>\n",
       "      <th>VTI1A</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>sample</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>MO_1008-Tumor_Dura</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>MO_1012-Tumor-Subcutaneous_nodule</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>MO_1013-Tumor</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>MO_1014-Tumor</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>MO_1015-Tumor</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 47 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                   AFDN  ARHGAP5  BIRC6  CLTC  CUX1  EIF4A2  \\\n",
       "sample                                                                        \n",
       "MO_1008-Tumor_Dura                  0.0      0.0    0.0   0.0   0.0     1.0   \n",
       "MO_1012-Tumor-Subcutaneous_nodule   NaN      NaN    NaN   NaN   NaN     NaN   \n",
       "MO_1013-Tumor                       NaN      NaN    NaN   NaN   NaN     NaN   \n",
       "MO_1014-Tumor                       NaN      NaN    NaN   NaN   NaN     NaN   \n",
       "MO_1015-Tumor                       0.0      0.0    0.0   0.0   0.0     0.0   \n",
       "\n",
       "                                   ERG  GNA11  HMGN2P46  KIAA1549  ...    MYC  \\\n",
       "sample                                                             ...          \n",
       "MO_1008-Tumor_Dura                 0.0    0.0       0.0       0.0  ...    0.0   \n",
       "MO_1012-Tumor-Subcutaneous_nodule  NaN    NaN       NaN       NaN  ...    NaN   \n",
       "MO_1013-Tumor                      NaN    NaN       NaN       NaN  ...    NaN   \n",
       "MO_1014-Tumor                      NaN    NaN       NaN       NaN  ...    NaN   \n",
       "MO_1015-Tumor                      0.0    0.0       0.0       0.0  ...    0.0   \n",
       "\n",
       "                                   NF1  NSD3  PDE4DIP  PIK3CA  RPN1  SEPT9  \\\n",
       "sample                                                                       \n",
       "MO_1008-Tumor_Dura                 0.0   0.0      0.0     0.0   0.0    0.0   \n",
       "MO_1012-Tumor-Subcutaneous_nodule  NaN   NaN      NaN     NaN   NaN    NaN   \n",
       "MO_1013-Tumor                      NaN   NaN      NaN     NaN   NaN    NaN   \n",
       "MO_1014-Tumor                      NaN   NaN      NaN     NaN   NaN    NaN   \n",
       "MO_1015-Tumor                      0.0   0.0      0.0     0.0   0.0    0.0   \n",
       "\n",
       "                                   SYK  TMPRSS2  VTI1A  \n",
       "sample                                                  \n",
       "MO_1008-Tumor_Dura                 0.0      0.0    0.0  \n",
       "MO_1012-Tumor-Subcutaneous_nodule  NaN      NaN    NaN  \n",
       "MO_1013-Tumor                      NaN      NaN    NaN  \n",
       "MO_1014-Tumor                      NaN      NaN    NaN  \n",
       "MO_1015-Tumor                      0.0      0.0    0.0  \n",
       "\n",
       "[5 rows x 47 columns]"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fusions_matrix_full.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {},
   "outputs": [],
   "source": [
    "mapping_file = join(PROSTATE_DATA_PATH, 'raw_data/sample_mapping.tsv')\n",
    "mapping_ids = pd.read_csv(mapping_file, sep='\\t')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Tumor_Sample_Barcode</th>\n",
       "      <th>patient</th>\n",
       "      <th>rna_sample_id</th>\n",
       "      <th>tpm_col</th>\n",
       "      <th>fusion_name</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>TCGA-EJ-5499</td>\n",
       "      <td>PRAD-TCGA-EJ-5499-Tumor-SM-1U3IG</td>\n",
       "      <td>PRAD-EJ-5499-TP</td>\n",
       "      <td>PRAD-EJ-5499-TP_polyA</td>\n",
       "      <td>PRAD-EJ-5499-TP</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>MO_1012</td>\n",
       "      <td>MO_1012-Tumor-Abdomen_wall_nodule</td>\n",
       "      <td>MO_1012-Tumor-Subcutaneous_nodule</td>\n",
       "      <td>MO_1012-Tumor-Subcutaneous_nodule_polyA</td>\n",
       "      <td>MO_1012-Tumor-Subcutaneous_nodule</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>TCGA-CH-5752</td>\n",
       "      <td>PRAD-TCGA-CH-5752-Tumor-SM-1U3ID</td>\n",
       "      <td>PRAD-CH-5752-TP</td>\n",
       "      <td>PRAD-CH-5752-TP_polyA</td>\n",
       "      <td>PRAD-CH-5752-TP</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>06-134H1_LN</td>\n",
       "      <td>06-134H1_LN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>SC_9126</td>\n",
       "      <td>SC_9126_Tumor</td>\n",
       "      <td>SC_9126_Tumor</td>\n",
       "      <td>SC_9126_Tumor_tcap</td>\n",
       "      <td>SC_9126_Tumor</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Tumor_Sample_Barcode                            patient  \\\n",
       "0         TCGA-EJ-5499   PRAD-TCGA-EJ-5499-Tumor-SM-1U3IG   \n",
       "1              MO_1012  MO_1012-Tumor-Abdomen_wall_nodule   \n",
       "2         TCGA-CH-5752   PRAD-TCGA-CH-5752-Tumor-SM-1U3ID   \n",
       "3          06-134H1_LN                        06-134H1_LN   \n",
       "4              SC_9126                      SC_9126_Tumor   \n",
       "\n",
       "                       rna_sample_id                                  tpm_col  \\\n",
       "0                    PRAD-EJ-5499-TP                    PRAD-EJ-5499-TP_polyA   \n",
       "1  MO_1012-Tumor-Subcutaneous_nodule  MO_1012-Tumor-Subcutaneous_nodule_polyA   \n",
       "2                    PRAD-CH-5752-TP                    PRAD-CH-5752-TP_polyA   \n",
       "3                                NaN                                      NaN   \n",
       "4                      SC_9126_Tumor                       SC_9126_Tumor_tcap   \n",
       "\n",
       "                         fusion_name  \n",
       "0                    PRAD-EJ-5499-TP  \n",
       "1  MO_1012-Tumor-Subcutaneous_nodule  \n",
       "2                    PRAD-CH-5752-TP  \n",
       "3                                NaN  \n",
       "4                      SC_9126_Tumor  "
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mapping_ids.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {},
   "outputs": [],
   "source": [
    "df = mapping_ids[['Tumor_Sample_Barcode','fusion_name']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {},
   "outputs": [],
   "source": [
    "fusions_matrix_full_ = df.join(fusions_matrix_full,on='fusion_name',  how='inner')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>AFDN</th>\n",
       "      <th>ARHGAP5</th>\n",
       "      <th>BIRC6</th>\n",
       "      <th>CLTC</th>\n",
       "      <th>CUX1</th>\n",
       "      <th>EIF4A2</th>\n",
       "      <th>ERG</th>\n",
       "      <th>GNA11</th>\n",
       "      <th>HMGN2P46</th>\n",
       "      <th>KIAA1549</th>\n",
       "      <th>...</th>\n",
       "      <th>MYC</th>\n",
       "      <th>NF1</th>\n",
       "      <th>NSD3</th>\n",
       "      <th>PDE4DIP</th>\n",
       "      <th>PIK3CA</th>\n",
       "      <th>RPN1</th>\n",
       "      <th>SEPT9</th>\n",
       "      <th>SYK</th>\n",
       "      <th>TMPRSS2</th>\n",
       "      <th>VTI1A</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Tumor_Sample_Barcode</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>TCGA-EJ-5499</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>MO_1012</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>TCGA-CH-5752</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SC_9126</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>PROS01448-6115227-SM-67ERU</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 47 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                            AFDN  ARHGAP5  BIRC6  CLTC  CUX1  EIF4A2  ERG  \\\n",
       "Tumor_Sample_Barcode                                                        \n",
       "TCGA-EJ-5499                 0.0      0.0    0.0   0.0   0.0     0.0  0.0   \n",
       "MO_1012                      NaN      NaN    NaN   NaN   NaN     NaN  NaN   \n",
       "TCGA-CH-5752                 0.0      0.0    0.0   0.0   0.0     0.0  0.0   \n",
       "SC_9126                      NaN      NaN    NaN   NaN   NaN     NaN  NaN   \n",
       "PROS01448-6115227-SM-67ERU   NaN      NaN    NaN   NaN   NaN     NaN  NaN   \n",
       "\n",
       "                            GNA11  HMGN2P46  KIAA1549  ...    MYC  NF1  NSD3  \\\n",
       "Tumor_Sample_Barcode                                   ...                     \n",
       "TCGA-EJ-5499                  0.0       0.0       0.0  ...    0.0  0.0   0.0   \n",
       "MO_1012                       NaN       NaN       NaN  ...    NaN  NaN   NaN   \n",
       "TCGA-CH-5752                  0.0       0.0       0.0  ...    0.0  0.0   0.0   \n",
       "SC_9126                       NaN       NaN       NaN  ...    NaN  NaN   NaN   \n",
       "PROS01448-6115227-SM-67ERU    NaN       NaN       NaN  ...    NaN  NaN   NaN   \n",
       "\n",
       "                            PDE4DIP  PIK3CA  RPN1  SEPT9  SYK  TMPRSS2  VTI1A  \n",
       "Tumor_Sample_Barcode                                                           \n",
       "TCGA-EJ-5499                    0.0     0.0   0.0    0.0  0.0      0.0    0.0  \n",
       "MO_1012                         NaN     NaN   NaN    NaN  NaN      NaN    NaN  \n",
       "TCGA-CH-5752                    0.0     0.0   0.0    0.0  0.0      0.0    0.0  \n",
       "SC_9126                         NaN     NaN   NaN    NaN  NaN      NaN    NaN  \n",
       "PROS01448-6115227-SM-67ERU      NaN     NaN   NaN    NaN  NaN      NaN    NaN  \n",
       "\n",
       "[5 rows x 47 columns]"
      ]
     },
     "execution_count": 75,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# del fusions_matrix_full_['fusion_name']\n",
    "fusions_matrix_full_ = fusions_matrix_full_.set_index('Tumor_Sample_Barcode')\n",
    "fusions_matrix_full_.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(659, 47)"
      ]
     },
     "execution_count": 78,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fusions_matrix_full_.fillna(0., inplace=True)\n",
    "fusions_matrix_full_.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "metadata": {},
   "outputs": [],
   "source": [
    "fusions_matrix_full_.to_csv('fusion_genes.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "metadata": {},
   "outputs": [],
   "source": [
    "fusions_matrix_full_.index.to_frame().to_csv('samples_with_fusion_data.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [conda env:min_env]",
   "language": "python",
   "name": "conda-env-min_env-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.15"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
